
public class FabrikList extends List {

	// adds object to list if it is instanceof fabrik, returns true if so, false if not
	@Override
	public boolean add(Object element) {
		if(!(element instanceof Fabrik)) {
			return false;
		}
		return super.add(element);
	}
	
	// removes object with given identifier, true if element has been removed, false if id not string or not removed
	public boolean remove(Object objId) {
		if(!(objId instanceof String)) {
			return false;
		}
		Fabrik elementToRemove = getElement(objId);
		return super.remove(elementToRemove);
	}
	
	// returns the fabrik element, null if id is invalid (not string) or element not found
	@Override
	public Fabrik getElement(Object objId) {
		if(!(objId instanceof String)) {
			// returns null if objId is not of correct type
			return null;
		}
		String fabricName = (String)objId;
		Iterator it = iterator();
		while(it.hasNext()) {
			Fabrik f = (Fabrik)it.next();
			if(f.NAME.equals(fabricName)) {
				return f;
			}
		}
		return null;
	}

}
